package com.zqwh.yj.sdk.model;

import android.app.smdt.SmdtManager;
import android.content.ContentResolver;
import android.content.Context;

/**
 * Created by eason.yang on 2017/8/21.
 */
public class SmdtModelImpl implements SmdtModel {
    private Context mContext;
    private SmdtManager mSmdtManager;

    public SmdtModelImpl(Context context) {
        this.mContext = context;
        mSmdtManager = new SmdtManager(this.mContext);
    }

    @Override
    public int unlock(int gpio) {
        return mSmdtManager.smdtSetGpioValue(gpio, false);
    }

    @Override
    public int lock(int gpio) {
        return mSmdtManager.smdtSetGpioValue(gpio, true);
    }

    @Override
    public int getDoorStatus(int gpio) {
        return mSmdtManager.smdtReadGpioValue(gpio);
    }

    @Override
    public int setInternalGpioDirection(int io, int direction, int def) {
        return mSmdtManager.smdtSetGpioDirection(io, direction, def);
    }

    @Override
    public int getInternalGpioDirection(int io) {
        return mSmdtManager.smdtGetGpioDirection(io);
    }

    @Override
    public int setInternalGpioValue(int io, int value) {
        return mSmdtManager.smdtSetGpioValue(io, value==1);
    }

    @Override
    public int getInternalGpioValue(int io) {
        return mSmdtManager.smdtReadGpioValue(io);
    }

    @Override
    public int setExternalGpioDirection(int io, int direction, int def) {
        return mSmdtManager.smdtSetXrm117xGpioDirection(io, direction, def);
    }

    @Override
    public int getExternalGpioDirection(int io) {
        return mSmdtManager.smdtGetXrm117xGpioDirection(io);
    }

    @Override
    public int setExternalGpioValue(int io, int value) {
        return mSmdtManager.smdtSetXrm117xGpioValue(io, value);
    }

    @Override
    public int getExternalGpioValue(int io) {
        return mSmdtManager.smdtGetXrm117xGpioValue(io);
    }

    @Override
    public void setBrightness(ContentResolver resolver, int brightness) {
        mSmdtManager.setBrightness(resolver, brightness);
    }

    @Override
    public void setRotation(String rotationDegree) {
        mSmdtManager.setRotation(rotationDegree);
    }

    @Override
    public void setLcdBackLight(int value) {
        mSmdtManager.smdtSetLcdBackLight(value);
    }

    @Override
    public void reboot() {
        mSmdtManager.smdtReboot("reboot");
    }

    @Override
    public int watchDogEnable() {
        return mSmdtManager.smdtWatchDogEnable((char) 1);
    }

    @Override
    public int watchDogDisable() {
        return mSmdtManager.smdtWatchDogEnable((char) 0);
    }

    @Override
    public int watchDogFeed() {
        return mSmdtManager.smdtWatchDogFeed();
    }

    @Override
    public void execSuCmd(String command) {
        mSmdtManager.execSuCmd(command);
    }

    @Override
    public void rodControl(String status) {

    }
}
